#works with version 1.0.6
DEFAULT_LEANUX_PREFIX=/usr

pkg_configure(){
	make clean || true
	make -f Makefile-libbz2_so clean || true
	export PREFIX=${LEANUX_PREFIX}
}

pkg_compile(){
	#will make a static lib only
	CFLAGS_CUSTOM="${CFLAGS} -fPIC -D_FILE_OFFSET_BITS=64"
	make ${MAKE_JOBS} PREFIX=${LEANUX_PREFIX} "CFLAGS=${CFLAGS_CUSTOM}"

	#will make a dynamic lib only
	CFLAGS_CUSTOM="${CFLAGS} -fPIC -fpic -D_FILE_OFFSET_BITS=64"
	make -f Makefile-libbz2_so ${MAKE_JOBS} PREFIX=${LEANUX_PREFIX} "CFLAGS=${CFLAGS_CUSTOM}"
}

pkg_install(){
	#install only the static lib and the bins
	make ${MAKE_JOBS} install PREFIX=${LEANUX_PREFIX}

	rm -f ${LEANUX_PREFIX}/lib/libbz2.a

	#install manually the shared lib, and bzip2-shared
	cp -f libbz2.so.1.0.6 ${LEANUX_PREFIX}/lib
	ln -sf libbz2.so.1.0.6 ${LEANUX_PREFIX}/lib/libbz2.so.1.0
	ln -sf libbz2.so.1.0.6 ${LEANUX_PREFIX}/lib/libbz2.so
	cp -f bzip2-shared ${LEANUX_PREFIX}/bin/bzip2
}

files_and_dirs="
lib
lib/libbz2.so.1.0
lib/libbz2.so
lib/libbz2.so.1.0.6
include
include/bzlib.h
man
man/man1
man/man1/bzdiff.1
man/man1/bzip2.1
man/man1/bzmore.1
man/man1/bzgrep.1
man/man1/bzegrep.1
man/man1/bzcmp.1
man/man1/bzfgrep.1
man/man1/bzless.1
bin
bin/bzip2
bin/bzmore
bin/bzip2recover
bin/bzcmp
bin/bzless
bin/bzgrep
bin/bunzip2
bin/bzegrep
bin/bzcat
bin/bzdiff
bin/bzfgrep"
